//
//  CommonImageTableViewCell.m
//  YunDongAdmin
//
//  Created by lqq on 2018/9/6.
//  Copyright © 2018年 cloudfighting.com. All rights reserved.
//

#import "CommonImageTableViewCell.h"


@interface CommonImageTableViewCell ()
@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) UILabel *leftLabel;
@property (nonatomic, strong) UIImageView *arrowImageView;
@property (nonatomic, strong) UIView *bottomLineView;

@end



@implementation CommonImageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self configUI];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self configUI];
    }
    return self;
}

- (UIImageView *)iconImageView
{
    if (_iconImageView == nil) {
        _iconImageView = [[UIImageView alloc] init];
    }
    return _iconImageView;
}

- (UILabel *)leftLabel
{
    if (_leftLabel == nil) {
        _leftLabel = [[UILabel alloc] init];
        _leftLabel.textColor = HEXColor(@"333333");
        _leftLabel.font = RegularFont(14);
    }
    return _leftLabel;
}



- (UIImageView *)arrowImageView
{
    if (_arrowImageView == nil) {
        _arrowImageView = [[UIImageView alloc] init];
        _arrowImageView.image = IMG_NAME(@"ic_more");
    }
    return _arrowImageView;
}

- (UIView *)bottomLineView
{
    if (_bottomLineView == nil ) {
        _bottomLineView = [[UIView alloc] init];
        _bottomLineView.backgroundColor = HEXColor(@"E5E5E5");
    }
    return _bottomLineView;
}


- (void)configUI
{
    [self.contentView addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.width.height.equalTo(@(25));
        make.centerY.equalTo(self.contentView);
    }];
    
    [self.contentView addSubview:self.leftLabel];
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImageView.mas_right).offset(10);
        make.centerY.equalTo(self.contentView);
    }];
    
    
    [self.contentView addSubview:self.arrowImageView];
    [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-20);
        make.centerY.equalTo(self.contentView);
        make.height.equalTo(@(10));
        make.width.equalTo(@(6));
    }];
    
    
    [self.contentView addSubview:self.bottomLineView];
    [self.bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.contentView);
        make.height.equalTo(@(kOnePX));
    }];
    
}

- (void)refreshCellWithIconName:(NSString *)iconName leftText:(NSString *)leftText
{
    self.iconImageView.image = IMG_NAME(iconName);
    self.leftLabel.text = leftText;
}
@end
